package com.example.demo_news.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

//新闻图片与新闻是多一的关系
@Entity
@Table(name="newsphoto")
public class NewsPhoto {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    //图片标识
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
    //可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name="newsId")//设置在此表表中的关联字段(外键)
    @JsonIgnore
    private News news;
    //新闻Id
    private String path;
    //图片路径
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    
    public News getNews() {
        return news;
    }
    public void setNews(News news) {
        this.news = news;
    }
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
    
}
